package com.luff.thread.factory;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Create By The-Long time 2021/10/6 20:05
 **/

public class MyThreadFactory implements ThreadFactory {

    //原子类Integer起始数据为1
    private final AtomicInteger mThreadNum = new AtomicInteger(1);

    /*工厂制造线程*/
    @Override
    public Thread newThread(Runnable r) {
        Thread t = new Thread(r, "my-thread-" + mThreadNum.getAndIncrement());
        return t;
    }
}
